package com.czapl.tabs;

import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
import com.czapl.api.IUnit;
import com.czapl.api.IUnit.IUnitStatusChangedListener;
import com.czapl.mygdxgame.MyGdxGame;

public class UnitInfoTab extends CTab implements IUnitStatusChangedListener{

	Label m_labelHp;

	public UnitInfoTab(IUnit unit) {
		NinePatch patch = MyGdxGame.skin.get("button_default", NinePatch.class);
        Image image = new Image(unit.getAnimatedSprite());
        add(image);
        setBackground(new NinePatchDrawable(patch));
        row();
        Label labelName = new Label(unit.getName(), MyGdxGame.skin);
        add(labelName);
        row();
        m_labelHp = new Label((int)unit.getCurrentHp()+"/"+(int)unit.getMaxHp(), MyGdxGame.skin);
        add(m_labelHp);
        unit.setUnitStatusChangedListener(this);
	}

	@Override
	public void onUnitStatusChanged(IUnit unit) {
		 m_labelHp.setText((int)unit.getCurrentHp()+"/"+(int)unit.getMaxHp());
		
	}
}
